Skip to main content

Import

Usage

Make sure you have followed the Getting Started guide to get the collection address and chainId.

Examples

Example of implementing a market purchase (secondary sales) using the useBuyModal hook:
This example uses the useLowestListing hook from marketplace-sdk. If there is no lowestListing with the given parameters, it means there is no orderId available, and therefore the item cannot be bought.
1

Setup handler component with marketplace config validation

First, create a main component that handles marketplace configuration loading and validation:
2

Create market purchase component

Next, create the actual market purchase component that uses properly validated data:

Parameters

The hook accepts an optional callbacks object with the following properties:

Return Type

The hook returns an object with the following methods:

Methods

show

(args: BuyModalProps) => void Opens the buy modal with the specified parameters. The BuyModalProps can be either ShopBuyModalProps or MarketplaceBuyModalProps depending on the purchase type. For market purchases (Secondary sales):
For shop purchases (Primary sales):
Both types extend from BuyModalBaseProps:

close

() => void Closes the buy modal.

Notes

The useBuyModal hook provides a convenient way to manage the buy modal interface for collectible purchases. It handles:
  • Opening and closing the modal
  • Managing the purchase flow state
  • Error handling and success callbacks
  • Support for both primary and secondary sales